package com.example.demo.dao;

import com.example.demo.entity.HD;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface HDRepository  extends CrudRepository<HD, Integer>,JpaRepository<HD,Integer> {

    @Query(value = "select * from hd where hdno=:hdno", nativeQuery = true)
    HD findByHdno(@Param("hdno") String hdno);

    @Query(value = "select * from hd where kid=:kid", nativeQuery = true)
    List<HD> getAllHdByKid(@Param("kid") Integer kid);

    @Query(value = "select count(1) from hd where kid=:kid", nativeQuery = true)
    Integer findCountByKid(@Param("kid") Integer kid);

    @Query(value = "select * from hd where kid=:kid and hdno=:hdno", nativeQuery = true)
    List<HD> getAllHdByHdnoAndKno(@Param("kid") Integer kid,@Param("hdno") Integer hdno);

    @Query(value = "select count(1) from hd where kid=:kid and hdno=:hdno", nativeQuery = true)
    Integer findCountByKidAndHdno(Integer kid, Integer hdno);
}
